import React,{useEffect} from 'react'
import {useSelector,useDispatch} from "react-redux"
import {setCount,setList,reduceCount} from "../../../store/features/countReducer"

export default function Main() {
  const {count,list} = useSelector(state=>{
    return state.countRD
  })
  const dispatch = useDispatch()

  //修改count
  const changeCount = ()=>{
    dispatch(setCount(100))
  }

  const changeCount2 = ()=>{
    dispatch(reduceCount())
  }

  return (
    <div>
      <h2>Main</h2>
      <p>{count}</p>
      <button onClick={changeCount}>+</button>
      <button onClick={changeCount2}>-</button>
      <p>{list.length}</p>
      <button>修改list</button>
    </div>
  )
}
